# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: spider-mario <spidermario@free.fr>
# Contributor: Daniel Ehlers <danielehlers@mindeye.net>

pkgname=coin-or-cbc
pkgver=2.10.11
pkgrel=1
pkgdesc='COIN-OR branch-and-cut mixed integer programming solver'
arch=(loong64 x86_64)
url='https://github.com/coin-or/Cbc'
license=(EPL)
groups=(coin-or)
depends=(coin-or-asl
         coin-or-cgl
         coin-or-clp
         coin-or-coinutils
         coin-or-osi
         glibc
         gcc-libs)
makedepends=(nauty)
source=($pkgname-$pkgver.tar.gz::https://github.com/coin-or/Cbc/archive/refs/tags/releases/$pkgver.tar.gz)
sha256sums=('1fb591dd88336fdaf096b8e42e46111e41671a5eb85d4ee36e45baff1678bd33')

build() {
  cd Cbc-releases-$pkgver/Cbc
  ./configure --prefix=/usr \
              --enable-cbc-parallel \
              --with-cbc-lib=/usr/lib/libnauty.a --with-cbc-incdir=/usr/include/nauty
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd Cbc-releases-$pkgver/Cbc
  make test
}

package() {
  cd Cbc-releases-$pkgver/Cbc
  make DESTDIR="$pkgdir" install

# Remove nauty from linker flags in pc file, it is statically compiled
  sed -e 's|/usr/lib/libnauty.a||' -i "$pkgdir"/usr/lib/pkgconfig/cbc.pc
}
